// src/utils/storage.js  WebStorage存储工具

/** keys 用于定义存储在SessionStorage中所有的key */
export const keys = {
  CURRENT_USER: "CURRENT_USER",
  CITY: 'CITY',
  TOKEN: 'TOKEN'
}

export const storage = {
  /** 向sessionStorage中存数据 */
  set(key:string, value:object){
    localStorage.setItem(key, JSON.stringify(value))
  },
  
  /** 从sessionStorage中取数据 */
  get(key:string){
    const value = localStorage.getItem(key)
    if(value){
      return JSON.parse(value)
    }else {
      return null
    }
  }
}


